Learn R Programming

pomp (version 1.10)

Trajectory matching: Parameter estimation by fitting the trajectory of a model's deterministic skeleton to data

Description

This function attempts to match trajectories of a model's deterministic skeleton to data. Trajectory matching is equivalent to maximum likelihood estimation under the assumption that process noise is entirely absent, i.e., that all stochasticity is measurement error. Accordingly, this method uses only the skeleton and dmeasure components of a POMP model.

Usage

"traj.match"(object, start, est = character(0), method = c("Nelder-Mead","subplex","SANN","BFGS", "sannbox","nloptr"), transform = FALSE, ...) "traj.match"(object, est, transform, ...) "traj.match.objfun"(object, params, est, transform = FALSE, ...)

Arguments

object
A pomp object. If object has no skeleton slot, an error will be generated.
start
named numeric vector containing an initial guess for parameters. By default start=coef(object) if the latter exists.
params
optional named numeric vector of parameters. This should contain all parameters needed by the skeleton and dmeasure slots of object. In particular, any parameters that are to be treated as fixed should be present here. Parameter values given in params for parameters named in est will be ignored. By default, params=coef(object) if the latter exists.
est
character vector containing the names of parameters to be estimated. In the case of traj.match.objfun, the objective function that is constructed will assume that its argument contains the parameters in this order.
method
Optimization method. Choices are subplex, “sannbox”, and any of the methods used by optim.
transform
logical; if TRUE, optimization is performed on the transformed scale.
...
Extra arguments that will be passed either to the optimizer (optim, subplex, nloptr, or sannbox, via their control (optim, subplex, sannbox) or opts (nloptr) lists) or to the ODE integrator. In traj.match, extra arguments will be passed to the optimizer. In traj.match.objfun, extra arguments are passed to trajectory. If extra arguments are needed by both optimizer and trajectory, construct an objective function first using traj.match.objfun, then give this objective function to the optimizer.

Value

traj.match returns an object of class traj.matched.pomp. This class inherits from class pomp and contains the following additional slots:
Available methods for objects of this type include summary and logLik. The other slots of this object can be accessed via the $ operator.traj.match.objfun returns a function suitable for use as an objective function in an optim-like optimizer.

Details

In pomp, trajectory matching is the term used for maximizing the likelihood of the data under the assumption that there is no process noise. Specifically, traj.match calls an optimizer (optim, subplex, and sannbox are the currently supported options) to minimize an objective function. For any value of the model parameters, this objective function is calculated by
  1. computing the deterministic trajectory of the model given the parameters. This is the trajectory returned by trajectory, which relies on the model's deterministic skeleton as specified in the construction of the pomp object object.
  2. evaluating the negative log likelihood of the data under the measurement model given the deterministic trajectory and the model parameters. This is accomplished via the model's dmeasure slot. The negative log likelihood is the objective function's value.

The objective function itself --- in a form suitable for use with optim-like optimizers --- is created by a call to traj.match.objfun. Specifically, traj.match.objfun will return a function that takes a single numeric-vector argument that is assumed to cotain the parameters named in est, in that order.

See Also

trajectory, pomp, optim, subplex

Examples

Run this code
  pompExample(ou2)
  true.p <- c(
	      alpha.1=0.9,alpha.2=0,alpha.3=-0.4,alpha.4=0.99,
	      sigma.1=2,sigma.2=0.1,sigma.3=2,
	      tau=1,
              x1.0=50,x2.0=-50
	      )
  simdata <- simulate(ou2,nsim=1,params=true.p,seed=43553)
  guess.p <- true.p
  res <- traj.match(
		    simdata,
		    start=guess.p,
		    est=c('alpha.1','alpha.3','alpha.4','x1.0','x2.0','tau'),
		    maxit=2000,
		    method="Nelder-Mead",
		    reltol=1e-8
		    )

  summary(res)

  plot(range(time(res)),range(c(obs(res),states(res))),type='n',xlab="time",ylab="x,y")
  points(y1~time,data=as(res,"data.frame"),col='blue')
  points(y2~time,data=as(res,"data.frame"),col='red')
  lines(x1~time,data=as(res,"data.frame"),col='blue')
  lines(x2~time,data=as(res,"data.frame"),col='red')

  pompExample(ricker)
  ofun <- traj.match.objfun(ricker,est=c("r","phi"),transform=TRUE)
  optim(fn=ofun,par=c(2,0),method="BFGS")

  pompExample(bbs)
  ## some options are passed to the ODE integrator
  ofun <- traj.match.objfun(bbs,est=c("beta","gamma"),transform=TRUE,hmax=0.001,rtol=1e-6)
  optim(fn=ofun,par=c(0,-1),method="Nelder-Mead",control=list(reltol=1e-10))

Run the code above in your browser using DataLab